from time import*
a = open("m1_sorted.txt").readlines()
b = open("m2_reverse.txt").readlines()
c = open("m3_shuffle.txt").readlines()
mas1 = list()
mas2 = list()
mas3 = list()
for i in range(len(a)):
    mas1.append(int(a[i]))
z = len(mas1)
t1 = time()
for k in range(z-1):
    o = 0
    for r in range(z-k-1):
                if mas1[r]>mas1[r+1]:
                    mas1[r], mas1[r+1] = mas1[r+1],mas[r]
                    o+=1
    if o == 0:
        break
t11 = time()
for i in range(len(b)):
    mas2.append(int(b[i]))
z1 = len(mas2)
t2 = time()
for m in range(z1-1):
    o1 = 0
    for v in range(z1-m-1):
        if mas2[v]>mas2[v+1]:
            mas2[v], mas2[v+1] = mas2[v+1],mas2[v]
            o1+=1
    if o1 ==0:
        break
t22 = time()
for i in range(len(c)):
    mas3.append(int(c[i]))
z3 = len(mas3)
t3 = time()
for x in range(z3-1):
    o2 = 0
    for j in range(z3 - x - 1):
        if mas3[j]> mas3[j+1]:
            mas3[j],mas3[j+1] = mas3[j+1],mas3[j]
            o2+=1
    if o2 == 0:
        break
t33 = time()
g3 = t33 - t3
g2  = t22 - t2
g1 = t11 - t1
g3 *= 1000
g2 *= 1000
g1 *= 1000
print('m1_sorted ',int(g1),'milliseconds')
print('m2_reverse', int(g2),'milliseconds')
print('m3_shuffle', int(g3),'milliseconds')
